package com.luobo.found.bulider;

/**
 * 定义一个指导者
 *
 * @author : AnWen
 * @version :1.0
 * @email : anwen375@qq.com
 * @since : 2020/3/5 9:04
 */
public class ToyDirector {

    //默认的创建者
    private ToyBuilder toyBuilder = new DefaultToyBuilder();

    public ToyDirector() {

    }

    public ToyBuilder getToyBuilder() {
        return toyBuilder;
    }

    public void setToyBuilder(ToyBuilder toyBuilder) {
        this.toyBuilder = toyBuilder;
    }

    //指定创建者
    public ToyDirector(ToyBuilder toyBuilder) {
        this.toyBuilder = toyBuilder;
    }


    public Toy buildToy(String head, String body) {
        toyBuilder.init();
        toyBuilder.buildHead(head);
        toyBuilder.buildBody(body);
        return toyBuilder.getToy();
    }

}
